from abc import ABC, abstractmethod

from src.handler.hongbao import HongBaoConfig
from src.utils.BaseLogger import BaseLogger


class AbstractProcess(ABC, BaseLogger):
    def __init__(self, config, config_dict):
        super().__init__()
        self.config = config
        self.config_dict = config_dict

    @abstractmethod
    def check(self) -> dict:
        return {"check": False}

    def process(self) -> bool:
        check_result = self.check()
        if check_result["check"]:
            return self.do_process(check_result)
        else:
            return self.do_not_check(check_result)

    @abstractmethod
    def do_process(self, check_result: dict) -> bool:
        return True

    def do_not_check(self, check_result: dict) -> bool:
        return False

    def get_new_origin(self):
        return HongBaoConfig.config_to_tuple(self.config_dict.get("new_origin"))

